<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="TOKN">﻿</span><span class="COMM">/*
<span class='line'>  2</span> Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
<span class='line'>  3</span> For licensing, see LICENSE.html or http://ckeditor.com/license
<span class='line'>  4</span> */</span><span class="WHIT">
<span class='line'>  5</span>
<span class='line'>  6</span> </span><span class="COMM">/**
<span class='line'>  7</span>  * @fileOverview Defines the {@link CKEDITOR.dom.text} class, which represents
<span class='line'>  8</span>  *		a DOM text node.
<span class='line'>  9</span>  */</span><span class="WHIT">
<span class='line'> 10</span>
<span class='line'> 11</span> </span><span class="COMM">/**
<span class='line'> 12</span>  * Represents a DOM text node.
<span class='line'> 13</span>  * @constructor
<span class='line'> 14</span>  * @augments CKEDITOR.dom.node
<span class='line'> 15</span>  * @param {Object|String} text A native DOM text node or a string containing
<span class='line'> 16</span>  *		the text to use to create a new text node.
<span class='line'> 17</span>  * @param {CKEDITOR.dom.document} [ownerDocument] The document that will contain
<span class='line'> 18</span>  *		the node in case of new node creation. Defaults to the current document.
<span class='line'> 19</span>  * @example
<span class='line'> 20</span>  * var nativeNode = document.createTextNode( 'Example' );
<span class='line'> 21</span>  * var text = CKEDITOR.dom.text( nativeNode );
<span class='line'> 22</span>  * @example
<span class='line'> 23</span>  * var text = CKEDITOR.dom.text( 'Example' );
<span class='line'> 24</span>  */</span><span class="WHIT">
<span class='line'> 25</span> </span><span class="NAME">CKEDITOR.dom.text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">ownerDocument</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 26</span> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 27</span> </span><span class="WHIT">	</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'string'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 28</span> </span><span class="WHIT">		</span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">ownerDocument</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">ownerDocument.$</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">document</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">createTextNode</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">text</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 29</span>
<span class='line'> 30</span> </span><span class="WHIT">	</span><span class="COMM">// Theoretically, we should call the base constructor here</span><span class="WHIT">
<span class='line'> 31</span> </span><span class="WHIT">	</span><span class="COMM">// (not CKEDITOR.dom.node though). But, IE doesn't support expando</span><span class="WHIT">
<span class='line'> 32</span> </span><span class="WHIT">	</span><span class="COMM">// properties on text node, so the features provided by domObject will not</span><span class="WHIT">
<span class='line'> 33</span> </span><span class="WHIT">	</span><span class="COMM">// work for text nodes (which is not a big issue for us).</span><span class="WHIT">
<span class='line'> 34</span> </span><span class="WHIT">	</span><span class="COMM">//</span><span class="WHIT">
<span class='line'> 35</span> </span><span class="WHIT">	</span><span class="COMM">// CKEDITOR.dom.domObject.call( this, element );</span><span class="WHIT">
<span class='line'> 36</span>
<span class='line'> 37</span> </span><span class="WHIT">	</span><span class="COMM">/**
<span class='line'> 38</span> 	 * The native DOM text node represented by this class instance.
<span class='line'> 39</span> 	 * @type Object
<span class='line'> 40</span> 	 * @example
<span class='line'> 41</span> 	 * var element = new CKEDITOR.dom.text( 'Example' );
<span class='line'> 42</span> 	 * alert( element.$.nodeType );  // "3"
<span class='line'> 43</span> 	 */</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="WHIT">	</span><span class="NAME">this.$</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">text</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 46</span>
<span class='line'> 47</span> </span><span class="NAME">CKEDITOR.dom.text.prototype</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">CKEDITOR.dom.node</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 48</span>
<span class='line'> 49</span> </span><span class="NAME">CKEDITOR.tools.extend</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">CKEDITOR.dom.text.prototype</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 50</span> </span><span class="WHIT">	</span><span class="COMM">/** @lends CKEDITOR.dom.text.prototype */</span><span class="WHIT">
<span class='line'> 51</span> </span><span class="WHIT">	</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 52</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 53</span> 		 * The node type. This is a constant value set to
<span class='line'> 54</span> 		 * {@link CKEDITOR.NODE_TEXT}.
<span class='line'> 55</span> 		 * @type Number
<span class='line'> 56</span> 		 * @example
<span class='line'> 57</span> 		 */</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">		</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">CKEDITOR.NODE_TEXT</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 59</span>
<span class='line'> 60</span> </span><span class="WHIT">		</span><span class="NAME">getLength</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 61</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 62</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.$.nodeValue.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 63</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 64</span>
<span class='line'> 65</span> </span><span class="WHIT">		</span><span class="NAME">getText</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 66</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 67</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.$.nodeValue</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 68</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 69</span>
<span class='line'> 70</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 71</span> 		 * Breaks this text node into two nodes at the specified offset,
<span class='line'> 72</span> 		 * keeping both in the tree as siblings. This node then only contains
<span class='line'> 73</span> 		 * all the content up to the offset point. A new text node, which is
<span class='line'> 74</span> 		 * inserted as the next sibling of this node, contains all the content
<span class='line'> 75</span> 		 * at and after the offset point. When the offset is equal to the
<span class='line'> 76</span> 		 * length of this node, the new node has no data.
<span class='line'> 77</span> 		 * @param {Number} The position at which to split, starting from zero.
<span class='line'> 78</span> 		 * @returns {CKEDITOR.dom.text} The new text node.
<span class='line'> 79</span> 		 */</span><span class="WHIT">
<span class='line'> 80</span> </span><span class="WHIT">		</span><span class="NAME">split</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">offset</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 81</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="WHIT">			</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">CKEDITOR.dom.text</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">this.$.splitText</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">offset</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 83</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'> 84</span>
<span class='line'> 85</span> </span><span class="WHIT">		</span><span class="COMM">/**
<span class='line'> 86</span> 		 * Extracts characters from indexA up to but not including indexB.
<span class='line'> 87</span> 		 * @param {Number} indexA An integer between 0 and one less than the
<span class='line'> 88</span> 		 *		length of the text.
<span class='line'> 89</span> 		 * @param {Number} [indexB] An integer between 0 and the length of the
<span class='line'> 90</span> 		 *		string. If omitted, extracts characters to the end of the text.
<span class='line'> 91</span> 		 */</span><span class="WHIT">
<span class='line'> 92</span> </span><span class="WHIT">		</span><span class="NAME">substring</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">indexA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">indexB</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">		</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 94</span> </span><span class="WHIT">			</span><span class="COMM">// We need the following check due to a Firefox bug</span><span class="WHIT">
<span class='line'> 95</span> </span><span class="WHIT">			</span><span class="COMM">// https://bugzilla.mozilla.org/show_bug.cgi?id=458886</span><span class="WHIT">
<span class='line'> 96</span> </span><span class="WHIT">			</span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="WHIT"> </span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">indexB</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="WHIT">
<span class='line'> 97</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.$.nodeValue.substr</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">indexA</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 98</span> </span><span class="WHIT">			</span><span class="KEYW">else</span><span class="WHIT">
<span class='line'> 99</span> </span><span class="WHIT">				</span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">this.$.nodeValue.substring</span><span class="PUNC">(</span><span class="WHIT"> </span><span class="NAME">indexA</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">indexB</span><span class="WHIT"> </span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>100</span> </span><span class="WHIT">		</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">	</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>102</span> </span></pre></body></html>
